package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName:TownEntity
 * ChineseName:行政区域镇（乡）类
 */
@Component("townEntity")
@Entity
@Table(name = "T_Town", schema = "crebas", catalog = "")
public class TownEntity {
    private String pkTTownId;
    private String townName;
    private String townPhoneticcode;

    private CountyEntity countyEntity;//县（区）

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "pk_t_county_id")
    public CountyEntity getCountyEntity() {
        return countyEntity;
    }

    public void setCountyEntity(CountyEntity countyEntity) {
        this.countyEntity = countyEntity;
    }

    @Id
    @Column(name = "pk_t_town_id", nullable = false, length = 5)
    public String getPkTTownId() {
        return pkTTownId;
    }

    public void setPkTTownId(String pkTTownId) {
        this.pkTTownId = pkTTownId;
    }

    @Basic
    @Column(name = "town_name", nullable = false, length = 30)
    public String getTownName() {
        return townName;
    }

    public void setTownName(String townName) {
        this.townName = townName;
    }

    @Basic
    @Column(name = "town_phoneticcode", nullable = false, length = 100)
    public String getTownPhoneticcode() {
        return townPhoneticcode;
    }

    public void setTownPhoneticcode(String townPhoneticcode) {
        this.townPhoneticcode = townPhoneticcode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TownEntity that = (TownEntity) o;

        if (pkTTownId != null ? !pkTTownId.equals(that.pkTTownId) : that.pkTTownId != null) return false;
        if (townName != null ? !townName.equals(that.townName) : that.townName != null) return false;
        return townPhoneticcode != null ? townPhoneticcode.equals(that.townPhoneticcode) : that.townPhoneticcode == null;

    }

    @Override
    public int hashCode() {
        int result = pkTTownId != null ? pkTTownId.hashCode() : 0;
        result = 31 * result + (townName != null ? townName.hashCode() : 0);
        result = 31 * result + (townPhoneticcode != null ? townPhoneticcode.hashCode() : 0);
        return result;
    }
}
